*     *****************************************************************   *;
*     *****************************************************************   *; 
*   Date:          December 27, 2021                               	      *;
*   Authors:       Lisa Dellmuth and Jonas Tallberg				          *;  
*   Purpose: 	   Analyses for book on elite communication and citizen   *;
*				   legitimacy beliefs toward international organizations  *;
*				   with Cambridge University Press 						  *;
*     ****************************************************************    *;
*     ****************************************************************    *;

*Chapter 6

vers 14.2

capture log close


use ch6.dta, clear


*     ****************************************************************    *;
*     recode															  *;
*     ****************************************************************    *;


*Education

gen edu=.
label var edu "Education, standardized"
tab education_DE
tab education_DE,nol
tab voceduc_neu_DE
tab voceduc_neu_DE, nol
tab educ_US
tab education_a_ph
tab education_a_ph, nol
tab edu_SA_1, nol
tab edu_SA_3, nol

*Secondary DE bis Realschule; in US highschool
*Lehre und vergleichbarer Abschluss ist postsecondary

replace edu=1 if education_DE==5|voceduc_neu_DE==1|education_a_ph==97|educ_US==1|edu_SA_3==6

replace edu=2 if education_DE==2|education_DE==3|voceduc_neu_DE==2| ///
voceduc_neu_DE==3|education_DE==4| ///
educ_US==2|edu_SA_1==1|edu_SA_1==2|education_a_ph==1 ///
|education_a_ph==2

replace edu=3 if voceduc_neu_DE==4|educ_US==3|educ_US==4 ///
|education_a_ph==3| edu_SA_3==3| edu_SA_3==4

replace edu=4 if voceduc_neu_DE==5|educ_US==5|educ_US==6 ///
|education_a_ph==4|education_a_ph==5|education_a_ph==6|edu_SA_1==3| ///
edu_SA_1==4|edu_SA_3==1|edu_SA_3==2|edu_SA_3==5

label define edu 1 "No formal qualifications or primary school" 2 "Secondary education" ///
3 "Post-secondary non-tertiary education" 4 "Tertiary education", modify
label values edu edu


*Gender
tab gender, nol
rename gender sex
recode sex (1=0) (2=1), gen(gender)

*News
tab q1
recode q1 (1=3) (2=2) (3=1) (4=.), gen(news)

*Discussion of politics with friends	
tab q2, nol
recode q2 (3=0) (2=1) (1=2) (4=.), gen(discuss)

*Generalized trust	
tab q3, nol
recode q3 (11=.), gen(trust)

*Cosmopolitan identity	
tab q13_1

gen cosmoid =.
replace cosmoid=0 if cosmoid==.|q13_1==1|q13_1==2|q13_2==1|q13_2==2
replace cosmoid=1 if cosmoid==.&q13_3==1|q13_4==1
replace cosmoid=1 if cosmoid==.&q13_3==2|q13_4==1
replace cosmoid=1 if cosmoid==.&q13_3==1|q13_4==2
label var cosmoid "1 if EU or world first and the others third, fourth, or not mentioned, 0 if otherwise"
tab cosmoid

*Left-right
tab q4, nol
recode q4 (11=.), gen(lr) 
label define lr 0 "0-Left" 10 "10-Right", modify

*confgov toward cultural diversity

tab q14
recode q14 (11=.), gen(tolerance) 


*Confidence in national government

tab q5
tab q5, nol
recode q5 (11=.), gen(confgov) 



*Confidence in national government - eff

tab q6a
recode q6a (11=.), gen(goveff) 

*Confidence in national government - dem

tab q6b
recode q6b (11=.), gen(govdem) 



*Confidence in national government - fair

tab q6c
recode q6c (11=.), gen(govfair) 


*Interest in GGIs

tab q11a
tab q11a, nol
recode q11a (4=0) (1=3) (3=1) (5=.), gen(interest_un)

tab q11b
tab q11b, nol
recode q11b (4=0) (1=3) (3=1) (5=.), gen(interest_imf)

compress
save ch6_final.dta

preserve
gen exa=q7a
gen exb=q7b
gen exc=q7c
gen exd=q7d
gen exe=q7e
gen exf=q7f
gen exg=q7g
gen exh=q7h
gen exi=q7i
gen exj=q7j
gen exk=q7k
gen exl=q7l
gen exm=q7m // control group
drop q7a-q10m
gen io=1
label define io 1 "UNSC" 2 "UNFCCC" 3 "IMF" 4 "ASEAN" 5 "AU" 6 "EU" 7 "NAFTA"
label values io io
tab io
save unsc.dta

preserve
gen exa=q8a
gen exb=q8b
gen exc=q8c
gen exd=q8d
gen exe=q8e
gen exf=q8f
gen exg=q8g
gen exh=q8h
gen exi=q8i
gen exj=q8j
gen exk=q8k
gen exl=q8l
gen exm=q8m // control group
drop q7a-q10m
gen io=2
label define io 1 "UNSC" 2 "UNFCCC" 3 "IMF" 4 "ASEAN" 5 "AU" 6 "EU" 7 "NAFTA"
label values io io
tab io
save unfccc.dta

preserve
gen exa=q9a
gen exb=q9b
gen exc=q9c
gen exd=q9d
gen exe=q9e
gen exf=q9f
gen exg=q9g
gen exh=q9h
gen exi=q9i
gen exj=q9j
gen exk=q9k
gen exl=q9l
gen exm=q9m // control group
drop q7a-q10m
gen io=3
label define io 1 "UNSC" 2 "UNFCCC" 3 "IMF" 4 "ASEAN" 5 "AU" 6 "EU" 7 "NAFTA"
label values io io
tab io
save imf.dta

gen exa=q10a
gen exb=q10b
gen exc=q10c
gen exd=q10d
gen exe=q10e
gen exf=q10f
gen exg=q10g
gen exh=q10h
gen exi=q10i
gen exj=q10j
gen exk=q10k
gen exl=q10l
gen exm=q10m // control group
drop q7a-q10m
gen io=4
label define io 1 "UNSC" 2 "UNFCCC" 3 "IMF" 4 "ASEAN" 5 "AU" 6 "EU" 7 "NAFTA"
label values io io
tab country
replace io=6 if country==1
replace io=7 if country==2
replace io=5 if country==3
tab io
save regional.dta

append using imf.dta
append using unsc.dta
append using unfccc.dta
tab io
tab country

tab exa
recode exa (11=.), gen(exar)
recode exb (11=.), gen(exbr)
recode exc (11=.), gen(excr)
recode exd (11=.), gen(exdr)
recode exe (11=.), gen(exer)
recode exf (11=.), gen(exfr)
recode exg (11=.), gen(exgr)
recode exh (11=.), gen(exhr)
recode exi (11=.), gen(exir)
recode exj (11=.), gen(exjr)
recode exk (11=.), gen(exkr)
recode exl (11=.), gen(exlr)
recode exm (11=.), gen(exmr)

egen conf=rowtotal(exar exbr excr exdr exer exfr exgr exhr exir exjr exkr exlr exmr), missing	

compress
save ch6_final.dta, replace




*     ****************************************************************    *;
*     Table 6.1 and Figure 6.1											  *;
*     ****************************************************************    *;


use ch6_final.dta, clear
*svyset id [pweight=weight], strata(country)

gen t_dem_p=.
replace t_dem_p=1 if exar!=.|excr!=.
replace t_dem_p=0 if exmr!=.

gen t_tech_p=.
replace t_tech_p=1 if exer!=.|exgr!=.
replace t_tech_p=0 if exmr!=.

gen t_fair_p=.
replace t_fair_p=1 if exir!=.|exkr!=.
replace t_fair_p=0 if exmr!=.

gen t_procedures_p=.
replace t_procedures_p=0 if exmr!=.
replace t_procedures_p=1 if exar!=.|exer!=.|exir!=.

gen t_out_p=.
replace t_out_p=0 if exmr!=.
replace t_out_p=1 if excr!=.|exgr!=.|exkr!=.

gen t_dem_p_in=.
replace t_dem_p_in=0 if exmr!=.
replace t_dem_p_in=1 if exar!=.

gen t_tech_p_in=.
replace t_tech_p_in=0 if exmr!=.
replace t_tech_p_in=1 if exer!=.

gen t_fair_p_in=.
replace t_fair_p_in=0 if exmr!=.
replace t_fair_p_in=1 if exir!=.

gen t_dem_p_out=.
replace t_dem_p_out=0 if exmr!=.
replace t_dem_p_out=1 if excr!=.

gen t_tech_p_out=.
replace t_tech_p_out=0 if exmr!=.
replace t_tech_p_out=1 if exgr!=.

gen t_fair_p_out=.
replace t_fair_p_out=0 if exmr!=.
replace t_fair_p_out=1 if exkr!=.

*save ch6_final.dta, replace



*Appendix Table O.1

reg conf t_dem_p_in [aweight=weight], cluster(RecordNo) 
eststo demp

reg conf t_tech_p_in  [aweight=weight], cluster(RecordNo) 
eststo techp

reg conf t_fair_p_in  [aweight=weight], cluster(RecordNo)  
eststo fairp
 
reg conf t_dem_p_out   [aweight=weight], cluster(RecordNo) 
eststo demperf
 
reg conf t_tech_p_out  [aweight=weight], cluster(RecordNo)  
eststo techperf

reg conf t_fair_p_out  [aweight=weight], cluster(RecordNo)  
eststo fairperf

esttab demp  techp  fairp demperf techperf fairperf using tableO.1.rtf, ///
bic scalars(N) replace b(%9.3f) t(%9.3f) starlevels(* .05 ** .01 *** .001)
 
 
 
*Fig.6.1 
preserve
reg conf t_dem_p_in [aweight=weight], cluster(RecordNo) 
parmest, label norestore escal(N) saving(demp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_in [aweight=weight], cluster(RecordNo) 
parmest, label norestore escal(N) saving(techp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_in [aweight=weight], cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_dem_p_out [aweight=weight], cluster(RecordNo) 
parmest, label norestore escal(N) saving(demperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_out [aweight=weight], cluster(RecordNo) 
parmest, label norestore escal(N) saving(techperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_out [aweight=weight], cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore



use demp.dta, clear
merge 1:1 parm using techp.dta
drop _merge
merge 1:1 parm using fairp.dta
drop _merge
merge 1:1 parm using demperf.dta
drop _merge
merge 1:1 parm using techperf.dta
drop _merge
merge 1:1 parm using fairperf.dta
drop _merge
saveold fig6.1.dta, replace

ed
drop in 1
drop label 
save fig6.1.dta, replace


use fig6.1.dta, clear

gen tg=.
replace tg=1 if parm=="t_dem_p_in"
replace tg=2 if parm=="t_dem_p_out"
replace tg=3 if parm=="t_tech_p_in"
replace tg=4 if parm=="t_tech_p_out"
replace tg=5 if parm=="t_fair_p_in"
replace tg=6 if parm=="t_fair_p_out"
		
rename min95 yl
rename max95 yu
rename estimate ate
			
local varname ate
local group1 tg

gen x = _n 

separate ate, by(tg)
separate yu, by(tg)
separate yl, by(tg)

twoway (scatter ate x , msymbol(S) msize(medium) mcolor(black)) ///
       (rcap yu yl x, lcolor(black))  ///
       (scatter ate x , msymbol(Oh) msize(large) mcolor(black)) ///
       (rcap yu yl x, lcolor(black) )  ///
       (scatter ate x , msymbol(T) msize(medium) mcolor(black)) ///
       (rcap yu yl x, lcolor(black) ), scheme(lean1)  ///
	   xlabel(none) xtitle(" ", size(3)) b2("Treatment groups compared to control group") ///
	   ytitle(Average treatment effect, size(3)) yscale(r(0(.2).8)) ///
	   text(-.15 1 "Democratic procedure", place(e) size(2.5)) ///
	   text(-.15 2 "Democratic performance", place(e) size(2.5)) ///
	   text(-.15 3 "Technocratic procedure", place(e) size(2.5)) ///
	   text(-.15 4 "Technocratic performance", place(e) size(2.5)) ///
	   text(-.15 5 "Fair procedure", place(e) size(2.5)) ///
	   text(-.1 5.75 "Fair performance", place(e) size(2.5)) ///
	   name(fig6_1, replace) graphregion(color(white)) ylab(, labsize(2.5) nogrid) ///
	   yline(0, lcolor(black) lpattern(dash))
		   
	   *Adjust x-title manually


	   
	   
	   
*     ****************************************************************    *;
*     Figure 6.2														  *;
*     ****************************************************************    *;


use ch6_final.dta, clear

preserve
keep RecordNo exmr conf country io weight id
graph dot conf if exmr!=. [aweight=weight], exclude0 over(io) 





*     ****************************************************************    *;
*     Interaction analysis - Appendix O2-O3								  *;
*     ****************************************************************    *;


use ch6_final.dta, clear

reg conf i.t_dem_p_in##c.edu  [aweight=weight], cluster(RecordNo)
eststo demp

reg conf i.t_tech_p_in##c.edu   [aweight=weight], cluster(RecordNo)
eststo techp

reg conf i.t_fair_p_in##c.edu   [aweight=weight], cluster(RecordNo)
eststo fairp
 
reg conf i.t_dem_p_out##c.edu   [aweight=weight], cluster(RecordNo)
eststo demperf
 
reg conf i.t_tech_p_out##c.edu   [aweight=weight], cluster(RecordNo)
eststo techperf

reg conf i.t_fair_p_out##c.edu   [aweight=weight], cluster(RecordNo)
eststo fairperf

esttab demp  techp  fairp demperf techperf fairperf using ch6_interactions-edu-table.O.2.rtf, ///
bic scalars(N) replace b(%9.3f) t(%9.3f) starlevels(* .05 ** .01 *** .001)
	
	
tab discuss	
reg conf i.t_dem_p_in##c.discuss  [aweight=weight], cluster(RecordNo)
eststo demp

reg conf i.t_tech_p_in##c.discuss   [aweight=weight], cluster(RecordNo)
eststo techp

reg conf i.t_fair_p_in##c.discuss   [aweight=weight], cluster(RecordNo)
eststo fairp
 
reg conf i.t_dem_p_out##c.discuss  [aweight=weight], cluster(RecordNo)
eststo demperf
 
reg conf i.t_tech_p_out##c.discuss   [aweight=weight], cluster(RecordNo)
eststo techperf

reg conf i.t_fair_p_out##c.discuss   [aweight=weight], cluster(RecordNo)
eststo fairperf

esttab demp  techp  fairp demperf techperf fairperf using ch6_interactions-discuss-table.O.3.rtf, ///
bic scalars(N) replace b(%9.3f) t(%9.3f) starlevels(* .05 ** .01 *** .001)
	   	   
	   
	   
	   
	 
	   
*     ****************************************************************    *;
*     Figures 6.3-4 and corresponding Appendix Table O 					  *;
*     ****************************************************************    *;
	     
	   
* Appendix Table // both input/output, and dem, tech, fair

reg conf t_dem_p_in if country==1   [aweight=weight], cluster(RecordNo)
eststo demp

reg conf t_tech_p_in if country==1   [aweight=weight], cluster(RecordNo)
eststo techp

reg conf t_fair_p_in if country==1   [aweight=weight], cluster(RecordNo)
eststo fairp 

esttab demp  techp fairp  using tableO.4_procedures_ger.rtf, ///
bic scalars(N) replace b(%9.3f) t(%9.3f) starlevels(* .05 ** .01 *** .001)
 

reg conf t_dem_p_in if country==2   [aweight=weight], cluster(RecordNo)
eststo demp

reg conf t_tech_p_in if country==2   [aweight=weight], cluster(RecordNo)
eststo techp

reg conf t_fair_p_in if country==2   [aweight=weight], cluster(RecordNo)
eststo fairp
 
esttab demp  techp  fairp  using tableO.4_procedures_us.rtf, ///
bic scalars(N) replace b(%9.3f) t(%9.3f) starlevels(* .05 ** .01 *** .001)
  
  
reg conf t_dem_p_in if country==3  [aweight=weight], cluster(RecordNo)
eststo demp

reg conf t_tech_p_in if country==3  [aweight=weight], cluster(RecordNo)
eststo techp

reg conf t_fair_p_in if country==3  [aweight=weight], cluster(RecordNo)
eststo fairp
 
esttab demp  techp  fairp  using tableO.4_procedures_zaf.rtf, ///
bic scalars(N) replace b(%9.3f) t(%9.3f) starlevels(* .05 ** .01 *** .001)
 	   
	   
reg conf t_dem_p_in if country==4  [aweight=weight], cluster(RecordNo)
eststo demp

reg conf t_tech_p_in if country==4  [aweight=weight], cluster(RecordNo)
eststo techp

reg conf t_fair_p_in if country==4  [aweight=weight], cluster(RecordNo)
eststo fairp

esttab demp  techp  fairp using tableO.4_procedures_phi.rtf, ///
bic scalars(N) replace b(%9.3f) t(%9.3f) starlevels(* .05 ** .01 *** .001)
 	   
	 

reg conf t_dem_p_out if country==1   [aweight=weight], cluster(RecordNo)
eststo demp

reg conf t_tech_p_out if country==1   [aweight=weight], cluster(RecordNo)
eststo techp

reg conf t_fair_p_out if country==1   [aweight=weight], cluster(RecordNo)
eststo fairp 

esttab demp  techp fairp  using tableO.4_performance_ger.rtf, ///
bic scalars(N) replace b(%9.3f) t(%9.3f) starlevels(* .05 ** .01 *** .001)
 

reg conf t_dem_p_out if country==2   [aweight=weight], cluster(RecordNo)
eststo demp

reg conf t_tech_p_out if country==2   [aweight=weight], cluster(RecordNo)
eststo techp

reg conf t_fair_p_out if country==2   [aweight=weight], cluster(RecordNo)
eststo fairp
 
esttab demp  techp  fairp  using tableO.4_performance_us.rtf, ///
bic scalars(N) replace b(%9.3f) t(%9.3f) starlevels(* .05 ** .01 *** .001)
  
  
reg conf t_dem_p_out if country==3  [aweight=weight], cluster(RecordNo)
eststo demp

reg conf t_tech_p_out if country==3  [aweight=weight], cluster(RecordNo)
eststo techp

reg conf t_fair_p_out if country==3  [aweight=weight], cluster(RecordNo)
eststo fairp
 
esttab demp  techp  fairp  using tableO.4_performance_zaf.rtf, ///
bic scalars(N) replace b(%9.3f) t(%9.3f) starlevels(* .05 ** .01 *** .001)
 	   
	   
reg conf t_dem_p_out if country==4  [aweight=weight], cluster(RecordNo)
eststo demp

reg conf t_tech_p_out if country==4  [aweight=weight], cluster(RecordNo)
eststo techp

reg conf t_fair_p_out if country==4  [aweight=weight], cluster(RecordNo)
eststo fairp

esttab demp  techp  fairp using tableO.4_performance_phi.rtf, ///
bic scalars(N) replace b(%9.3f) t(%9.3f) starlevels(* .05 ** .01 *** .001)
 	   
	 

	 

use ch6_final.dta, clear

tab io

preserve
reg conf t_dem_p_in [aweight=weight] if io==1, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_in [aweight=weight] if io==1, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_in [aweight=weight] if io==1, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_dem_p_out [aweight=weight] if io==1, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_out [aweight=weight] if io==1, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_out [aweight=weight] if io==1, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore



use demp.dta, clear
merge 1:1 parm using techp.dta
drop _merge
merge 1:1 parm using fairp.dta
drop _merge
merge 1:1 parm using demperf.dta
drop _merge
merge 1:1 parm using techperf.dta
drop _merge
merge 1:1 parm using fairperf.dta
drop _merge
saveold fig6.34_unsc.dta, replace


use ch6_final.dta, clear

preserve
reg conf t_dem_p_in [aweight=weight] if io==2, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_in [aweight=weight] if io==2, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_in [aweight=weight] if io==2, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_dem_p_out [aweight=weight] if io==2, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_out [aweight=weight] if io==2, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_out [aweight=weight] if io==2, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore



use demp.dta, clear
merge 1:1 parm using techp.dta
drop _merge
merge 1:1 parm using fairp.dta
drop _merge
merge 1:1 parm using demperf.dta
drop _merge
merge 1:1 parm using techperf.dta
drop _merge
merge 1:1 parm using fairperf.dta
drop _merge
saveold fig6.34_unfccc.dta, replace


use ch6_final.dta, clear

preserve
reg conf t_dem_p_in [aweight=weight] if io==3, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_in [aweight=weight] if io==3, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_in [aweight=weight] if io==3, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_dem_p_out [aweight=weight] if io==3, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_out [aweight=weight] if io==3, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_out [aweight=weight] if io==3, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore



use demp.dta, clear
merge 1:1 parm using techp.dta
drop _merge
merge 1:1 parm using fairp.dta
drop _merge
merge 1:1 parm using demperf.dta
drop _merge
merge 1:1 parm using techperf.dta
drop _merge
merge 1:1 parm using fairperf.dta
drop _merge
saveold fig6.34_imf.dta, replace


use ch6_final.dta, clear

preserve
reg conf t_dem_p_in [aweight=weight] if io==4, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_in [aweight=weight] if io==4, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_in [aweight=weight] if io==4, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_dem_p_out [aweight=weight] if io==4, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_out [aweight=weight] if io==4, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_out [aweight=weight] if io==4, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore



use demp.dta, clear
merge 1:1 parm using techp.dta
drop _merge
merge 1:1 parm using fairp.dta
drop _merge
merge 1:1 parm using demperf.dta
drop _merge
merge 1:1 parm using techperf.dta
drop _merge
merge 1:1 parm using fairperf.dta
drop _merge
saveold fig6.34_asean.dta, replace



use ch6_final.dta, clear

preserve
reg conf t_dem_p_in [aweight=weight] if io==5, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_in [aweight=weight] if io==5, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_in [aweight=weight] if io==5, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_dem_p_out [aweight=weight] if io==5, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_out [aweight=weight] if io==5, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_out [aweight=weight] if io==5, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore



use demp.dta, clear
merge 1:1 parm using techp.dta
drop _merge
merge 1:1 parm using fairp.dta
drop _merge
merge 1:1 parm using demperf.dta
drop _merge
merge 1:1 parm using techperf.dta
drop _merge
merge 1:1 parm using fairperf.dta
drop _merge
saveold fig6.34_au.dta, replace



use ch6_final.dta, clear

preserve
reg conf t_dem_p_in [aweight=weight] if io==6, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_in [aweight=weight] if io==6, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_in [aweight=weight] if io==6, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_dem_p_out [aweight=weight] if io==6, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_out [aweight=weight] if io==6, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_out [aweight=weight] if io==6, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore



use demp.dta, clear
merge 1:1 parm using techp.dta
drop _merge
merge 1:1 parm using fairp.dta
drop _merge
merge 1:1 parm using demperf.dta
drop _merge
merge 1:1 parm using techperf.dta
drop _merge
merge 1:1 parm using fairperf.dta
drop _merge
saveold fig6.34_eu.dta, replace



use ch6_final.dta, clear

preserve
reg conf t_dem_p_in [aweight=weight] if io==7, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_in [aweight=weight] if io==7, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_in [aweight=weight] if io==7, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_dem_p_out [aweight=weight] if io==7, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_out [aweight=weight] if io==7, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_out [aweight=weight] if io==7, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore



use demp.dta, clear
merge 1:1 parm using techp.dta
drop _merge
merge 1:1 parm using fairp.dta
drop _merge
merge 1:1 parm using demperf.dta
drop _merge
merge 1:1 parm using techperf.dta
drop _merge
merge 1:1 parm using fairperf.dta
drop _merge
saveold fig6.34_nafta.dta, replace



use fig6.34_unsc.dta, clear
gen io=1
append using fig6.34_unfccc.dta 
replace io=2 if io==.
append using fig6.34_imf.dta 
replace io=3 if io==.
append using fig6.34_asean.dta 
replace io=4 if io==.
append using fig6.34_au.dta 
replace io=5 if io==.
append using fig6.34_eu.dta 
replace io=6 if io==.
append using fig6.34_nafta.dta 
replace io=7 if io==.
saveold fig6.34.dta, replace

sort p
ed

sort parm
drop in 1/7
drop label 
save fig6.34.dta, replace


use fig6.34.dta, clear
ed

gen tg=.
replace tg=1 if parm=="t_dem_p_in"
replace tg=2 if parm=="t_dem_p_out"
replace tg=3 if parm=="t_tech_p_in"
replace tg=4 if parm=="t_tech_p_out"
replace tg=5 if parm=="t_fair_p_in"
replace tg=6 if parm=="t_fair_p_out"
		
rename min95 yl
rename max95 yu
rename estimate ate
			
local varname ate
local group1 tg
local group2 io
sort `group1' `group2'

gen x = _n
replace x = _n + 2 if _n >= 6
replace x = _n + 4 if _n >= 11

separate ate, by(io)
separate yu, by(io)
separate yl, by(io)

sort io
ed

twoway (scatter ate1 x , msymbol(S) msize(medium) mcolor(black)) ///
       (rcap yu1 yl1 x, lcolor(black))  ///
       (scatter ate2 x , msymbol(Oh) msize(large) mcolor(black)) ///
       (rcap yu2 yl2 x, lcolor(black) )  ///
       (scatter ate3 x , msymbol(T) msize(medium) mcolor(black)) ///
       (rcap yu3 yl3 x, lcolor(black) ), scheme(lean1)  ///
	   xlabel(none) xtitle(" ", size(3)) b2("Treatment groups compared to control group") ///
	   ytitle(Average treatment effect, size(3)) yscale(r(0.25(.25)1)) ///
	   text(-.3 1 "Democratic procedure", place(e) size(2.5)) ///
	   text(-.3 3 "Democratic performance", place(e) size(2.5)) ///
	   text(-.3 15 "Technocratic procedure", place(e) size(2.5)) ///
	   text(-.3 19 "Technocratic performance", place(e) size(2.5)) ///
	   text(-.3 22 "Fair procedure", place(e) size(2.5)) ///
	   text(-.3 26 "Fair performance", place(e) size(2.5)) ///
	   legend(order(1 "UNSC" 3 "UNFCCC" 5 "IMF") position(1) row(1) ring(0)) ///
	   name(fig6_3, replace) graphregion(color(white)) ylab(, labsize(2.5) nogrid) ///
	   yline(0, lcolor(black) lpattern(dash))
	
twoway (scatter ate4 x , msymbol(T) msize(medium) mcolor(black)) ///
       (rcap yu4 yl4 x, lcolor(black) )  ///
       (scatter ate5 x , msymbol(T) msize(medium) mcolor(black)) ///
       (rcap yu5 yl5 x, lcolor(black) )  ///
       (scatter ate6 x , msymbol(T) msize(medium) mcolor(black)) ///
       (rcap yu6 yl6 x, lcolor(black) )  ///
       (scatter ate7 x , msymbol(D) msize(medium) mcolor(black)) ///
       (rcap yu7 yl7 x, lcolor(black) ), scheme(lean1)  ///
	   xlabel(none) xtitle(" ", size(3)) b2("Treatment groups compared to control group") ///
	   ytitle(Average treatment effect, size(3)) yscale(r(0.75(.25)1.25)) ///
	   text(-1.1 1 "Democratic procedure", place(e) size(2.5)) ///
	   text(-1.1 7 "Democratic performance", place(e) size(2.5)) ///
	   text(-1.1 15 "Technocratic procedure", place(e) size(2.5)) ///
	   text(-1.1 19 "Technocratic performance", place(e) size(2.5)) ///
	   text(-1.1 22 "Fair procedure", place(e) size(2.5)) ///
	   text(-1.1 26 "Fair performance", place(e) size(2.5)) ///
	   legend(order(1 "ASEAN" 3 "AU" 5 "EU" 7 "NAFTA") position(1) row(1) ring(0)) ///
	   name(fig6_4, replace) graphregion(color(white)) ylab(, labsize(2.5) nogrid) ///
	   yline(0, lcolor(black) lpattern(dash))
	
	 	   
	   
	   

*IMF

tab io

reg conf t_dem_p_in [aweight=weight] if io==3, cluster(RecordNo)
eststo demp

reg conf t_tech_p_in [aweight=weight] if io==3, cluster(RecordNo)
eststo techp

reg conf t_fair_p_in [aweight=weight] if io==3, cluster(RecordNo)
eststo fairp

reg conf t_dem_p_out [aweight=weight] if io==3, cluster(RecordNo)
eststo demperf
 
reg conf t_tech_p_out [aweight=weight] if io==3, cluster(RecordNo)
eststo techperf

reg conf t_fair_p_out [aweight=weight] if io==3, cluster(RecordNo)
eststo fairperf
 
esttab demp  techp  fairp demperf techperf fairperf using tableO.5_imf.rtf, ///
bic scalars(N) replace b(%9.3f) t(%9.3f) starlevels(* .05 ** .01 *** .001)


*UNSC

reg conf t_dem_p_in [aweight=weight] if io==1, cluster(RecordNo)
eststo demp
 
reg conf t_tech_p_in [aweight=weight] if io==1, cluster(RecordNo)
eststo techp
 
reg conf t_fair_p_in [aweight=weight] if io==1, cluster(RecordNo)
eststo fairp
 
reg conf t_dem_p_out [aweight=weight] if io==1, cluster(RecordNo)
eststo demperf

reg conf t_tech_p_out [aweight=weight] if io==1, cluster(RecordNo)
eststo techperf
 
reg conf t_fair_p_out [aweight=weight] if io==1, cluster(RecordNo)
eststo fairperf
 
esttab demp  techp  fairp demperf techperf fairperf using tableO.5_unsc.rtf, ///
bic scalars(N) replace b(%9.3f) t(%9.3f) starlevels(* .05 ** .01 *** .001)


*UNFCCC

reg conf t_dem_p_in [aweight=weight] if io==2, cluster(RecordNo)
eststo demp
 
reg conf t_tech_p_in [aweight=weight] if io==2, cluster(RecordNo)
eststo techp

reg conf t_fair_p_in [aweight=weight] if io==2, cluster(RecordNo)
eststo fairp
 
reg conf t_dem_p_out [aweight=weight] if io==2, cluster(RecordNo)
eststo demperf

reg conf t_tech_p_out [aweight=weight] if io==2, cluster(RecordNo)
eststo techperf
 
reg conf t_fair_p_out [aweight=weight] if io==2, cluster(RecordNo)
eststo fairperf
 
esttab demp  techp  fairp demperf techperf fairperf using tableO.5_unfccc.rtf, ///
bic scalars(N) replace b(%9.3f) t(%9.3f) starlevels(* .05 ** .01 *** .001) 


*ASEAN 

reg conf t_dem_p_in [aweight=weight] if io==4, cluster(RecordNo)
eststo demp
 
reg conf t_tech_p_in [aweight=weight] if io==4, cluster(RecordNo)
eststo techp

reg conf t_fair_p_in [aweight=weight] if io==4, cluster(RecordNo)
eststo fairp
 
reg conf t_dem_p_out [aweight=weight] if io==4, cluster(RecordNo)
eststo demperf

reg conf t_tech_p_out [aweight=weight] if io==4, cluster(RecordNo)
eststo techperf
 
reg conf t_fair_p_out [aweight=weight] if io==4, cluster(RecordNo)
eststo fairperf
 
esttab demp  techp  fairp demperf techperf fairperf using tableO.5_asean.rtf, ///
bic scalars(N) replace b(%9.3f) t(%9.3f) starlevels(* .05 ** .01 *** .001) 

*AU 

reg conf t_dem_p_in [aweight=weight] if io==5, cluster(RecordNo)
eststo demp
 
reg conf t_tech_p_in [aweight=weight] if io==5, cluster(RecordNo)
eststo techp

reg conf t_fair_p_in [aweight=weight] if io==5, cluster(RecordNo)
eststo fairp
 
reg conf t_dem_p_out [aweight=weight] if io==5, cluster(RecordNo)
eststo demperf

reg conf t_tech_p_out [aweight=weight] if io==5, cluster(RecordNo)
eststo techperf
 
reg conf t_fair_p_out [aweight=weight] if io==5, cluster(RecordNo)
eststo fairperf
 
esttab demp  techp  fairp demperf techperf fairperf using tableO.5_au.rtf, ///
bic scalars(N) replace b(%9.3f) t(%9.3f) starlevels(* .05 ** .01 *** .001) 

*EU 

reg conf t_dem_p_in [aweight=weight] if io==6, cluster(RecordNo)
eststo demp
 
reg conf t_tech_p_in [aweight=weight] if io==6, cluster(RecordNo)
eststo techp

reg conf t_fair_p_in [aweight=weight] if io==6, cluster(RecordNo)
eststo fairp
 
reg conf t_dem_p_out [aweight=weight] if io==6, cluster(RecordNo)
eststo demperf

reg conf t_tech_p_out [aweight=weight] if io==6, cluster(RecordNo)
eststo techperf
 
reg conf t_fair_p_out [aweight=weight] if io==6, cluster(RecordNo)
eststo fairperf
 
esttab demp  techp  fairp demperf techperf fairperf using tableO.5_eu.rtf, ///
bic scalars(N) replace b(%9.3f) t(%9.3f) starlevels(* .05 ** .01 *** .001) 

*NAFTA 

reg conf t_dem_p_in [aweight=weight] if io==7, cluster(RecordNo)
eststo demp
 
reg conf t_tech_p_in [aweight=weight] if io==7, cluster(RecordNo)
eststo techp

reg conf t_fair_p_in [aweight=weight] if io==7, cluster(RecordNo)
eststo fairp
 
reg conf t_dem_p_out [aweight=weight] if io==7, cluster(RecordNo)
eststo demperf

reg conf t_tech_p_out [aweight=weight] if io==7, cluster(RecordNo)
eststo techperf
 
reg conf t_fair_p_out [aweight=weight] if io==7, cluster(RecordNo)
eststo fairperf
 
esttab demp  techp  fairp demperf techperf fairperf using tableO.5_nafta.rtf, ///
bic scalars(N) replace b(%9.3f) t(%9.3f) starlevels(* .05 ** .01 *** .001) 



	

*     ****************************************************************    *;
*     Figure 6.5														  *;
*     ****************************************************************    *;


use ch6_final.dta, clear

gen one=1
graph bar (percent) one [aweight=weight], ytitle(Knowledge about the IMF) over(q12a_result) saving(12a.gph)
graph bar (percent) one [aweight=weight], ytitle(Knowledge about the UN) over(q12b_result) saving(12b.gph) 
graph combine 12a.gph 12b.gph, ycommon



	 
*Fig.6.6


use ch6_final.dta, clear

tab io

preserve
reg conf t_dem_p_in [aweight=weight] if io==1, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_in [aweight=weight] if io==1, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_in [aweight=weight] if io==1, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_dem_p_out [aweight=weight] if io==1, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_out [aweight=weight] if io==1, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_out [aweight=weight] if io==1, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore



use demp.dta, clear
merge 1:1 parm using techp.dta
drop _merge
merge 1:1 parm using fairp.dta
drop _merge
merge 1:1 parm using demperf.dta
drop _merge
merge 1:1 parm using techperf.dta
drop _merge
merge 1:1 parm using fairperf.dta
drop _merge
saveold fig6.6_ger.dta, replace


use ch6_final.dta, clear

preserve
reg conf t_dem_p_in [aweight=weight] if country==2, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_in [aweight=weight] if country==2, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_in [aweight=weight] if country==2, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_dem_p_out [aweight=weight] if country==2, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_out [aweight=weight] if country==2, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_out [aweight=weight] if country==2, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore



use demp.dta, clear
merge 1:1 parm using techp.dta
drop _merge
merge 1:1 parm using fairp.dta
drop _merge
merge 1:1 parm using demperf.dta
drop _merge
merge 1:1 parm using techperf.dta
drop _merge
merge 1:1 parm using fairperf.dta
drop _merge
saveold fig6.6_us.dta, replace


use ch6_final.dta, clear

preserve
reg conf t_dem_p_in [aweight=weight] if country==3, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_in [aweight=weight] if country==3, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_in [aweight=weight] if country==3, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_dem_p_out [aweight=weight] if country==3, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_out [aweight=weight] if country==3, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_out [aweight=weight] if country==3, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore



use demp.dta, clear
merge 1:1 parm using techp.dta
drop _merge
merge 1:1 parm using fairp.dta
drop _merge
merge 1:1 parm using demperf.dta
drop _merge
merge 1:1 parm using techperf.dta
drop _merge
merge 1:1 parm using fairperf.dta
drop _merge
saveold fig6.6_zaf.dta, replace


use ch6_final.dta, clear

preserve
reg conf t_dem_p_in [aweight=weight] if country==4, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_in [aweight=weight] if country==4, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_in [aweight=weight] if country==4, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairp.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_dem_p_out [aweight=weight] if country==4, cluster(RecordNo) 
parmest, label norestore escal(N) saving(demperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_tech_p_out [aweight=weight] if country==4, cluster(RecordNo) 
parmest, label norestore escal(N) saving(techperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore

preserve
reg conf t_fair_p_out [aweight=weight] if country==4, cluster(RecordNo) 
parmest, label norestore escal(N) saving(fairperf.dta, replace)
list parm estimate stderr dof min95 max95, clean noobs 
restore



use demp.dta, clear
merge 1:1 parm using techp.dta
drop _merge
merge 1:1 parm using fairp.dta
drop _merge
merge 1:1 parm using demperf.dta
drop _merge
merge 1:1 parm using techperf.dta
drop _merge
merge 1:1 parm using fairperf.dta
drop _merge
saveold fig6.6_phi.dta, replace



use fig6.4_ger.dta, clear
gen country=1
append using fig6.4_us.dta 
replace country=4 if country==.
append using fig6.4_zaf.dta 
replace country=3 if country==.
append using fig6.4_phi.dta 
replace country=2 if country==.
saveold fig6.6.dta, replace


ed
sort parm
drop in 1/4
drop label 
save fig6.6.dta, replace


use fig6.6.dta, clear
ed

gen tg=.
replace tg=1 if parm=="t_dem_p_in"
replace tg=2 if parm=="t_dem_p_out"
replace tg=3 if parm=="t_tech_p_in"
replace tg=4 if parm=="t_tech_p_out"
replace tg=5 if parm=="t_fair_p_in"
replace tg=6 if parm=="t_fair_p_out"
		
rename min95 yl
rename max95 yu
rename estimate ate
			
local varname ate
local group1 tg
local group2 country
sort `group1' `group2'

gen x = _n
replace x = _n + 2 if _n >= 6
replace x = _n + 4 if _n >= 11
replace x = _n + 6 if _n >= 16
replace x = _n + 8 if _n >= 21
replace x = _n + 10 if _n >= 26

separate ate, by(country)
separate yu, by(country)
separate yl, by(country)


twoway (scatter ate1 x , msymbol(S) msize(medium) mcolor(black)) ///
       (rcap yu1 yl1 x, lcolor(black))  ///
       (scatter ate2 x , msymbol(Oh) msize(large) mcolor(black)) ///
       (rcap yu2 yl2 x, lcolor(black) )  ///
       (scatter ate3 x , msymbol(T) msize(medium) mcolor(black)) ///
       (rcap yu3 yl3 x, lcolor(black) )  ///
       (scatter ate4 x , msymbol(D) msize(medium) mcolor(black)) ///
       (rcap yu4 yl4 x, lcolor(black) ), scheme(lean1)  ///
	   xlabel(none) xtitle(" ", size(3)) b2("Treatment groups compared to control group") ///
	   ytitle(Average treatment effect, size(3)) yscale(r(0.75(.25)1.5)) ///
	   text(-.6 1 "Democratic procedure", place(e) size(2.5)) ///
	   text(-.6 5 "Democratic performance", place(e) size(2.5)) ///
	   text(-.6 9 "Technocratic procedure", place(e) size(2.5)) ///
	   text(-.6 13 "Technocratic performance", place(e) size(2.5)) ///
	   text(-.6 17 "Fair procedure", place(e) size(2.5)) ///
	   text(-.6 20 "Fair performance", place(e) size(2.5)) ///
	   legend(order(1 "Germany" 3 "Philippines" 5 "South Africa" 7 "US") position(1) row(1) ring(0)) ///
	   name(fig6_6, replace) graphregion(color(white)) ylab(, labsize(2.5) nogrid) ///
	   yline(0, lcolor(black) lpattern(dash))
	
	   
	

	
